import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:we_chat_app/chat_page.dart';
import 'package:we_chat_app/discover/discover_page.dart';
import 'package:we_chat_app/friend_page.dart';
import 'package:we_chat_app/my.dart';

class RootPage extends StatefulWidget{
  @override
  State createState()=> _State();
}

class _State extends State<RootPage> {
  int _current_index = 3;
  final List<StatefulWidget> _pageList = [ChatPage(),FriendPage(),DiscoverPage(),MyPage()];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pageList[_current_index],
      bottomNavigationBar: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          fixedColor: Colors.green,
          selectedFontSize: 14,
          unselectedFontSize: 12,
          currentIndex: _current_index,
          onTap: (index){
            setState(() {
              _current_index = index;
            });
          },
          items: const [
            BottomNavigationBarItem(icon: Icon(Icons.chat,),label: '消息',),
            BottomNavigationBarItem(icon: Icon(Icons.bookmark,),label: '通讯录'),
            BottomNavigationBarItem(icon: Icon(Icons.search,),label: '发现'),
            BottomNavigationBarItem(icon: Icon(Icons.person,),label: '我的')
          ]
      ),
    );
  }
}